<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateOrderLogsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('order_logs', function (Blueprint $table) {
            $table->id();
            $table->integer('order_id')->index()->comment('订单ID');
            $table->integer('member_id')->index()->comment('会员ID');
            $table->string('order_bn', 100)->index()->comment('订单编号');
            $table->enum('source', ['member','admin'])->default('admin')->comment('来源: member 用户端 admin 后台');
            $table->integer('op_id')->default(0)->comment('操作人ID');
            $table->string('op_name', 100)->comment('操作人姓名');
            $table->unsignedTinyInteger('behavior')->default(0)->comment('行为');
            $table->enum('status', ['success','fail'])->default('success')->comment('状态: success 成功 fail 管理员');
            $table->text('content')->nullable()->comment('操作说明');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('order_logs');
    }
}
